package com.chidopi.member.domain;

import java.util.Calendar;
import java.util.Date;

public class Member2SubscribeHis {
	private String email;
	private int city_id;
	private int sub_id;
	private Date order_date;
	private Date start_date;
	private Date end_date;
	private double overage;
	
	public Member2SubscribeHis() {}
	public Member2SubscribeHis(Member2Subscribe mem2sub) {
		this.email = mem2sub.getEmail();
		this.city_id = mem2sub.getCity_id();
		this.sub_id = mem2sub.getSub_id();
		this.order_date = Calendar.getInstance().getTime();
		this.start_date = mem2sub.getStart_date();
		this.end_date = mem2sub.getEnd_date();
		this.overage = mem2sub.getOverage();
	}
	
	// 用於同型續訂
	public Member2SubscribeHis(Member2Subscribe mem2sub, Subscriptions subs, Date start_date) {
		this.email = mem2sub.getEmail();
		this.city_id = mem2sub.getCity_id();
		this.sub_id = subs.getId();
		this.order_date = Calendar.getInstance().getTime();
		String unit = subs.getPeriod_unit();
		if ("amount".equals(unit)) {
			this.overage = subs.getPeriod_amount();
		} else if ("quota".equals(unit)) {
			this.overage = subs.getPeriod_quota();			
		} else {
			this.start_date = start_date;
			this.end_date = mem2sub.getEnd_date();
			this.overage =mem2sub.getOverage();
		}
		
	}
	
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public int getCity_id() {
		return city_id;
	}
	public void setCity_id(int city_id) {
		this.city_id = city_id;
	}
	public int getSub_id() {
		return sub_id;
	}
	public void setSub_id(int sub_id) {
		this.sub_id = sub_id;
	}
	public Date getOrder_date() {
		return order_date;
	}
	public void setOrder_date(Date order_date) {
		this.order_date = order_date;
	}
	public Date getStart_date() {
		return start_date;
	}
	public void setStart_date(Date start_date) {
		this.start_date = start_date;
	}
	public Date getEnd_date() {
		return end_date;
	}
	public void setEnd_date(Date end_date) {
		this.end_date = end_date;
	}
	public double getOverage() {
		return overage;
	}
	public void setOverage(double overage) {
		this.overage = overage;
	}
}
